/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package view;

import jade.core.AID;
import java.awt.Component;
import javax.swing.DefaultListCellRenderer;
import javax.swing.JLabel;
import javax.swing.JList;

/**
 *
 * @author CUNEYT
 *
 * This class is a specialised CellRenderer for the JList in order to display
 * a customised output in the list.
 *
 */
public class SMCellRenderer extends DefaultListCellRenderer {

    @Override
    public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {

        JLabel label = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);

        AID obj = (AID) value;
        label.setHorizontalTextPosition(JLabel.LEADING);
        label.setVerticalTextPosition(JLabel.CENTER);

        if (obj.getName().contains("museum")) {
            label.setText(obj.getLocalName() + " (museum/gallery)");
        } else if (obj.getName().contains("tour")) {
            label.setText(obj.getLocalName() + " (tour-guide)");
        } else {
            label.setText(obj.getName());
        }

        return label;
    }
}
